package demo1;

public class Test3 {
     static boolean isQuit = false ;
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(()->{
            while (!isQuit){
                System.out.println("run正在执行");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("run结束");
        });
        t1.start();
        System.out.println("五秒后run结束");
         Thread.sleep(5000);
        System.out.println("isQuit==true");
        isQuit = true ;

    }
}
